const connection = require("../app/database")
const {verifUser} = require("../middleware/user.middleware")
class UserServices {
  async create(user) {
    const {name, password} = user;
    const statement = `INSERT INTO users (name, password) VALUES (?, ?)`

    const result = await connection.execute(statement, [name, password])
    console.log("把数据保存到数据库中", user)
    // return "哈哈哈"
    return result;
  }

  // 登录查询
  async login(user) {
    const { name, password } = user;

    const statement = `SELECT * FROM users WHERE name = ? `;
    const result = await connection.execute(statement, [name]);
    console.log("查询结果56", result[0])
    
    // 数据库查数据
    // return "登陆成功"
    return result[0]
  } 
};


module.exports = new UserServices();